package com.github.ghsea.scheduler.entity;

import com.github.ghsea.scheduler.dto.Task;
import java.io.Serializable;
import java.util.Date;

/**
 * @author guhai
 * @since 2021/6/17 21:53
 */
public class TaskEntity implements Serializable {

    private Long id;

    private String bizCode;

    private Date stopTime;

    private int intervalSeconds;

    private String server;

    private int isAlive;

    /**
     * 数据版本号，用于乐观锁控制
     */
    private int version;

    public int getVersion() {
        return version;
    }

    public TaskEntity setVersion(int version) {
        this.version = version;
        return this;
    }

    public Long getId() {
        return id;
    }

    public TaskEntity setId(Long id) {
        this.id = id;
        return this;
    }

    public String getBizCode() {
        return bizCode;
    }

    public TaskEntity setBizCode(String bizCode) {
        this.bizCode = bizCode;
        return this;
    }

    public Date getStopTime() {
        return stopTime;
    }

    public TaskEntity setStopTime(Date stopTime) {
        this.stopTime = stopTime;
        return this;
    }

    public int getIntervalSeconds() {
        return intervalSeconds;
    }

    public TaskEntity setIntervalSeconds(int intervalSeconds) {
        this.intervalSeconds = intervalSeconds;
        return this;
    }

    public String getServer() {
        return server;
    }

    public TaskEntity setServer(String server) {
        this.server = server;
        return this;
    }

    public int getIsAlive() {
        return isAlive;
    }

    public TaskEntity setIsAlive(int isAlive) {
        this.isAlive = isAlive;
        return this;
    }

    public Task toTask() {
        Task task = new Task();
        task.setStopTime(this.getStopTime());
        task.setIntervalSeconds(this.getIntervalSeconds());
        task.setBizCode(this.getBizCode());

        return task;
    }

}
